package com.butterfly.hotkey.dashboard.biz.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.butterfly.hotkey.dashboard.biz.entity.User;
import com.butterfly.hotkey.dashboard.biz.enums.StateEnum;
import com.google.common.collect.Lists;

/**
 * <p>
 * 用户表 Mapper 接口
 * </p>
 *
 * @author butterfly
 * @since 2024-10-24
 */
public interface UserMapper extends BaseMapper<User> {


    /**
     * 查询登录用户，仅返回密码和ID
     *
     * @param username username
     * @return User
     */
    default User selectLoginUser(String username) {
        return selectOne(
                Wrappers.<User>lambdaQuery()
                        .select(Lists.newArrayList(User::getPwd, User::getId))
                        .eq(User::getUserName, username)
                        .eq(User::getState, StateEnum.ENABLE.getCode())
        );
    }

}
